EraseDayActionPrototype = {
    apply: function(repository, recordHistoryCallback) {
        var travelStepsToRemove = this._getTravelStepsToRemove();
        var monthsToSave = this._getMonthsToSave();
        recordHistoryCallback(monthsToSave, { add: travelStepsToRemove, remove: [] });

        this._eraseDays();
        repository.saveTravelSteps({ remove: travelStepsToRemove, add: [] });
        repository.markAsChanged(monthsToSave);
    },


    _getTravelStepsToRemove: function() {
        var travelSteps = [];
        this._days.foreach(function(day) {
            var travels = day.getTravelSteps();
            travels.foreach(function(travel) {
                travelSteps.uniquePush(travel);
            });
        });
        return travelSteps;
    },
    _getMonthsToSave: function() {
        var months = [];
        this._days.foreach(function(day) {
            months.uniquePush(day.parentMonth());
        });
        return months;
    }
};


function EraseDayActivityAction(days) {
    this._days = days;
    this._eraseDays = function() {
        this._days.foreach(function(day) {
            day.setActivity(DayActivity.empty);
            day.setSecondActivity(DayActivity.empty);
        });
    }
    this.applyUI = function(calendarViewBody) {
        calendarViewBody.updateDays(this._days);
    }
}
EraseDayActivityAction.prototype = EraseDayActionPrototype;

function EraseDayLocationAction(days) {
    this._days = days;
    this._eraseDays = function() {
        this._days.foreach(function(day) {
            day.setLocation(null);
        });
    }
    this.applyUI = function(calendarViewBody) {
        calendarViewBody.updateLocations();
    }
}
EraseDayLocationAction.prototype = EraseDayActionPrototype
   
